﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoadTeam.SysInterface;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Enums;

namespace RoadTeam.BsSystem.CS.HomeInspection
{
    public class TbCsDoorType_Sys : RtSysBase,ICsDoorType
    {
       public DataTable GetALLDoorTypeTable()
       {
           SqlWhere where = new SqlWhere();
           where.SelectColumn = @" DoorTypeID,App_Identifier ";
           return TbCsDoorType.Select(where, GlobalConfig.RtConnectionString);
       }
   
       public DataTable GetDoorTypeTable(String organID)
       {
           SqlWhere where = new SqlWhere();
           where.Info = new TbCsDoorType() { OrganID =Convert.ToDecimal(organID) };
           where.StrSqlWhere = @" App_Identifier Is  NULL  ";
           where.SelectColumn = @" DoorTypeName,DoorTypeCode,App_Identifier,OrganID,DoorTypeID";
           return TbCsDoorType.Select(where, GlobalConfig.RtConnectionString);
       }


       public DataTable GetDoorTypeNotNullTable(String organID)
       {
           SqlWhere where = new SqlWhere();
           where.Info = new TbCsDoorType() { OrganID = Convert.ToDecimal(organID) };
           where.StrSqlWhere = @" App_Identifier IS NOT NULL  ";
           where.SelectColumn = @" DoorTypeName,DoorTypeCode,App_Identifier,OrganID,DoorTypeID";
           return TbCsDoorType.Select(where, GlobalConfig.RtConnectionString);
       }



       public bool UpdateDoorTypeTable(DataTable dt)
       {
         return TbCsDoorType.Update(dt, GlobalConfig.RtConnectionString);
       }

       public DataTable GetDoorTypeData(String InID)
       {
           SqlWhere where = new SqlWhere();
           where.StrSqlWhere = @" DoorTypeID IN (" + InID + ")  ";
           return TbCsDoorType.Select(where, GlobalConfig.RtConnectionString);
       }

       public override string GetIdentitiferByID(String ID)
       {
           SqlWhere where = new SqlWhere();
           where.Info = new TbCsDoorType() { DoorTypeID = Convert.ToDecimal(ID) };
           where.SelectColumn = @" top 1 App_Identifier  ";
           DataTable dt = TbCsDoorType.Select(where, GlobalConfig.RtConnectionString);
           if (dt.Rows.Count == 0) return @"-1";
           return dt.Rows[0][0].ToString();
       }


    }
}
